package com.wanxi.controller;

import com.wanxi.dto.OrderDTO;
import com.wanxi.dto.ProductInstanceDTO;
import com.wanxi.entity.Patient;
import com.wanxi.result.CommonResult;
import com.wanxi.service.FrontGuardianService;
import com.wanxi.vo.*;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "监护人相关接口")
@RestController
@RequestMapping("/front/guardian")
public class FrontGuardianController {

    @Autowired
    private FrontGuardianService frontGuardianService;

    @ApiOperation(value = "查询监护人信息")
    @ApiResponses({
            @ApiResponse(code = 200,message = "OK",response = UserDTO.class)
    })
    @GetMapping("/findGuardian")
    public CommonResult findGuardian(UserQuery userQuery){
        return frontGuardianService.getGuardianByCondition(userQuery);
    }

    @ApiOperation(value = "查询个人信息")
    @ApiImplicitParam(name = "id",value = "用户id",required = true)
    @ApiResponses({
            @ApiResponse(code = 200,message = "OK",response = UserDTO.class)
    })
    @GetMapping("/findGuardianById")
    public CommonResult findGuardianById(Long id){
        UserQuery userQuery = new UserQuery();
        userQuery.setGuardianId(id);
        return frontGuardianService.getGuardianByCondition(userQuery);
    }

    @ApiOperation(value = "完善用户信息接口",response = CommonResult.class)
    @ApiImplicitParam(name = "id",value = "用户id",required = true)
    @PostMapping("/perfectInformation")
    public CommonResult perfectInformation(Long id, UserInfoDTO userInfoDTO){
        userInfoDTO.setId(id);
        return frontGuardianService.perfectInformation(userInfoDTO);
    }


    @ApiOperation(value = "查询监护人提供的患者")
    @ApiImplicitParam(name = "guardianId",value = "监护人id",required = true)
    @ApiResponses({
            @ApiResponse(code = 200,message = "OK",response = Patient.class,responseContainer = "List")
    })
    @GetMapping("/findPatientByGuardianId")
    public CommonResult findPatientByGuardianId(Long guardianId) {
        return frontGuardianService.findPatientByGuardianId(guardianId);
    }

    @ApiOperation(value = "下单接口",response = CommonResult.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "下单成功",response = OrderResult.class)
    })
    @PostMapping("/createOrder")
    public CommonResult<?> createOrder(OrderDTO orderDTO){

        return frontGuardianService.createOrder(orderDTO);
    }

    @ApiOperation(value = "购买接口",response = CommonResult.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "购买成功")
    })
    @PostMapping("/pay")
    public CommonResult<?> pay(){
        return null;
    }

    @ApiOperation(value = "查询监护人的订单信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guardianId",value = "监护人id",required = true),
            @ApiImplicitParam(name = "orderState",value = "订单状态",required = true)
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功",responseContainer = "List",response = OrderDTO.class)
    })
    @GetMapping("/findOrderByGuardianId")
    public CommonResult<?> findOrderByGuardianId(Long guardianId,Integer orderState){
        return frontGuardianService.findOrderByGuardianId(guardianId,orderState);
    }

    @PostMapping("/addAuthentication")
    @ApiOperation(value = "提交医生入驻申请", response = CommonResult.class)
    public CommonResult addAuthentication(DoctorApplyDTO doctorApplyDTO) {
        return frontGuardianService.addAuthentication(doctorApplyDTO);
    }

    @PutMapping("/findAccountStatus")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guardianId",value = "监护人id",required = true),
            @ApiImplicitParam(name = "businessStatus",value = "入驻状态",required = true)
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功",responseContainer = "List",response = DoctorApplyDTO.class)
    })
    @ApiOperation(value = "查询医生入驻申请")
    public CommonResult findAccountStatus(Long guardianId, Integer businessStatus) {
        return frontGuardianService.findAccountStatus(guardianId,businessStatus);
    }

    @ApiOperation(value = "添加患者审核申请",response = CommonResult.class)
    @PostMapping("/addPatientApply")
    public CommonResult addPatientApply(PatientApplyDTO patientApplyDTO){
        return frontGuardianService.addPatientApply(patientApplyDTO);
    }

    @ApiOperation(value = "查询监护人进行的服务包实体")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guardianId",value = "监护人id",required = true),
            @ApiImplicitParam(name = "serviceStatus",value = "服务包实体状态",required = true)
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "OK",response = ProductInstanceDTO.class,responseContainer = "List")
    })
    @GetMapping("/findProductEntityByGuardianId")
    public CommonResult findProductEntityByGuardianId(Long guardianId,Integer serviceStatus){
        return frontGuardianService.findProductEntityByGuardianId(guardianId,serviceStatus);
    }

    @ApiOperation(value = "切换医生接口",response = CommonResult.class)
    @ApiImplicitParams(
            @ApiImplicitParam(name = "id" ,value = "用户id",required = true)
    )

    @PostMapping("/switchDoctor")
    public CommonResult switchDoctor(Long id){
        return frontGuardianService.SwitchDoctor(id);
    }

}
